import 'package:flutter/material.dart';

class Widget_Checkbox_Page extends StatefulWidget {

  @override
  State<StatefulWidget> createState() {
    return Widget_Checkbox_State();
  }
}

class Widget_Checkbox_State extends State<Widget_Checkbox_Page> {
  bool isCheck = false;
  bool isCheck1 = false;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("Checkbox"),
        ),
        body: Column(
          children: <Widget>[
            Checkbox(
              value: isCheck,
              onChanged: (isChecked) {
                setState(() {
                  isCheck = isChecked;
                });
              },
              activeColor: Colors.red,
              checkColor: Colors.blue,
              materialTapTargetSize: MaterialTapTargetSize.padded,
            ),
            CheckboxListTile(
              value: isCheck1,
              onChanged: (isChecked) {
                setState(() {
                  isCheck1 = isChecked;
                });
              },
              activeColor: Colors.red,
              title: Text("标题"),
              subtitle: Text("副标题"),
              secondary: Icon(Icons.alarm),
//                selected:true
            controlAffinity: ListTileControlAffinity.trailing,
            )
          ],
        ),
      ),
    );
  }
}

/**
 * 复选框，点自己可以取消
 *const Checkbox({
    Key key,
    @required this.value,
    this.tristate = false,//设置true时，value可以为null，即可以为true，false，null
    @required this.onChanged,
    this.activeColor,//选中时的颜色
    this.checkColor,//选中时对号的颜色
    this.materialTapTargetSize,//点击区域尺寸，padded：向四周扩展48px区域;shrinkWrap：控件区域
    })
 */

/**
 * 系统封装的一个Checkbox
 *const CheckboxListTile({
    Key key,
    @required this.value,
    @required this.onChanged,
    this.activeColor,//选中颜色
    this.title,
    this.subtitle,
    this.isThreeLine = false,//设置为true，高度变大
    this.dense,
    this.secondary,//左侧图标
    this.selected = false,
    this.controlAffinity = ListTileControlAffinity.platform,//leading：secondary在右侧；trailing：secondary在左侧；platform：根据平台确定
    })
 */
